//
//  CAIUpgradeContentTableCell.m
//  CAIUpgradeManager
//
//  Created by 海参 on 2021/10/9.
//

#import "CAIUpgradeContentTableCell.h"
#import "CAIUpgradeTool.h"
#import <Masonry/Masonry.h>

@implementation CAIUpgradeContentTableCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        if (@available(iOS 14.0, *)) {
            self.backgroundConfiguration = [UIBackgroundConfiguration clearConfiguration];
        } else {
            // Fallback on earlier versions
            self.backgroundColor = [UIColor whiteColor];
        }
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self setUI];
    }
    return self;
}

- (void)setUI{
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.dotView];
    [self.dotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(3, 3));
    }];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left).offset(LCDScale_iPhone6(8));
        make.right.mas_equalTo(self.contentView.mas_right);
        make.top.mas_equalTo(self.contentView.mas_top).offset(LCDScale_iPhone6(4.5));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
    }];
}


- (void)setData:(NSString *)title
{
    self.titleLab.text = title;
}


- (void)layoutSubviews{
    [super layoutSubviews];
    self.dotView.layer.cornerRadius = 3.0/2;
    self.dotView.layer.masksToBounds = YES;
}

- (UILabel *)titleLab
{
    if (!_titleLab) {
        UILabel *lab = [[UILabel alloc] init];
        lab.font = [UIFont systemFontOfSize:LCDScale_iPhone6(12) weight:UIFontWeightRegular];
        lab.textColor = [UIColor caiUpdateColorWithHexString:@"#666666"];
        lab.numberOfLines = 0;
        lab.text = NSLocalizedString(@"", nil);
        _titleLab = lab;
    }
    return _titleLab;
}

- (UIView *)dotView{
    if (!_dotView) {
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor caiUpdateColorWithHexString:@"#D8D8D8"];
        _dotView = view;
    }
    return _dotView;
}
@end
